from flask import Flask
from .views import blue
from .exts import init_exts


def create_app(__name__):
    app = Flask(__name__, instance_relative_config=True)
    # 注册蓝图
    app.register_blueprint(blue)
    # 配置数据库
    db_url = 'sqlite:///tsg.db'
    app.config['SQLALCHEMY_DATABASE_URI'] = db_url
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False  # 禁止对象跟踪
    init_exts(app=app)
    return app
